import { getEducationAndTraining } from "@/api/login";

import { formatEducationAndTraining } from "@/utils/home";

const requestMetheds = {
  async getEducationAndTraining({ commit }, data) {
    let res = await getEducationAndTraining(data);
    commit("setEducationAndTraining", formatEducationAndTraining(res));
    return res;
  },
};
export default {
  ...requestMetheds,
  async InitHomePageData(store, data) {
    await store.dispatch("login",'InitHomePageData');
    store.commit("loading", true);
    return await Promise.all(
      Object.keys(requestMetheds).map((key) => requestMetheds[key](store, data))
    )
      .catch((error) => {
        store.dispatch("InitHomePageData");
      })
      .finally(() => store.commit("loading", false));
  },
};
